<?php if (!defined('THINK_PATH')) exit();?><div class="ajax_login">
  <div class="title">
  		<div class="logo"><img src="/<?php echo C('UU_IMG_DIR');?>ajax_login.png"/></div>
        <div class="close J_btncancel"></div>
  </div>
  
  <div class="lmain">
  
 	<div class="frombox">
			  <div class="tab">
			    	<div class="li select J_switch" data="J_type1">用户名登录</div>
					<div class="li J_switch" data="J_type2">手机动态码登录</div>
					<div class="clear"></div>
			  </div>
			  
				  <div class="login_type J_type1" style="display:block">
				<form action="" id="j_loginform" method="get">
					<div class="ce">
				      <div class="imgbg"></div>
							    <input name="username" type="text" maxlength="16" id="username" class="linput" placeholder="请输入用户名/手机号"  autocomplete="off"/>
				      </div>
				    <div class="ce">
				      <div class="imgbg pwd"></div>
					    <input name="password" type="password" id="password" value="" class="linput pwd" placeholder="请输入密码"  autocomplete="off"/>
				      </div>
					  
				    <div class="err"><!--错误提示 --></div>
				    <div class="ce">
				      <input class="btn" type="submit" name="Submit" id="J_dologin" value="登录" />
				      </div>
					  <div class="ce">
					 	 <div class="imgchecked_txt"><input name="auto"   type="hidden" value="0" />自动登录</div>	
					     <div class="getpwd link_gray3"><a href="javascript:void(0)" class="J_user_findpwd">忘记密码?</a></div>
					  </div>
					  </form>
      			</div>
				<div class="login_type J_type2">
				<form action="" id="j_loginform_mobile" method="get">
					<div class="ce">
				      <div class="imgbg"></div>
							    <input name="m_mobile" type="text" maxlength="11"   class="linput" placeholder="请输入手机号"  autocomplete="off"/>
								 <div class="send_code " id="J_send_code">获取验证码</div>
				      </div>
				    <div class="ce">
				      <div class="imgbg pwd"></div>
					    <input name="m_code" type="password"   value="" class="linput pwd" placeholder="请输入验证码"  autocomplete="off"/>
				      </div>
					  
				    <div class="err"><!--错误提示 --></div>
				    <div class="ce">
				      <input class="btn" type="submit" name="Submit" id="J_dologin_mobile" value="登录" />
				      </div>
					  <div class="ce">
					 	 <div class="imgchecked_txt"><input name="m_auto"   type="hidden" value="0" />自动登录</div>	
					     <div class="getpwd link_gray3"><a href="javascript:void(0)"  class="J_user_findpwd">忘记密码?</a></div>
					  </div>
					  </form>
				</div>
				 
 	</div>
	
  </div>
  
  <div class="rmain">
	<div class="tit">使用第三方账号登录</div>
	
    <div class="api_login">
		<?php if(is_array($oauth_list)): $i = 0; $__LIST__ = $oauth_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$oauth): $mod = ($i % 2 );++$i;?><a class="uu_api_login_btn <?php echo ($key); ?>" href="<?php echo U('callback/index',array('mod'=>$key,'type'=>'login'));?>"></a><?php endforeach; endif; else: echo "" ;endif; ?>
		<div class="clear"></div>
	</div>
	
	
    <div class="btnbox">
		<div class="btn_green btn_inline  btn_border J_user_reg">注册账号</div>
	</div>
	
  </div>
  
  <div class="clear"></div>
</div>
<script type="text/javascript">
$('.J_btncancel').die().click(function()
{
		$(".modal,.modal_backdrop").remove();
});
//用户名和密码登录
$("#j_loginform").die().submit( function () {
	$("#j_loginform .err").hide();
	username=$("#j_loginform input[name=username]").val();
	password=$("#j_loginform input[name=password]").val();
	auto=$("#j_loginform input[name=auto]").val();
	
  if (username=='' || password==''){
  	disapperTooltip("remind",'用户名和密码不能为空！');
  	$("#j_loginform .err").show().html('用户名和密码不能为空！');
  }
  else
  {
  		$("#J_dologin").val('登录中...').attr("disabled","disabled");
		 $.getJSON(ajaxURL, { act: "ajax_user_login_verify",username:username,password:password,auto:auto}, function(json){
			if (json.status==0){
				$("#J_dologin").val('登录').removeAttr("disabled");
				disapperTooltip("remind",json.content);
				$("#j_loginform .err").show().html(json.content);
			}else if (json.status==1){
			
					$(".modal,.modal_backdrop").remove();
					disapperTooltip("success",json.content);					
						setTimeout(function () { 
							window.location.reload();
						}, 1800);
				//window.location.reload();
			}else{
				$("#J_dologin").val('登录').removeAttr("disabled");
				$("#j_loginform .err").show().html('未知错误');
			}
		});
  		
  }
  return false;
} );

//切换
//切换登录类型
 $(".J_switch").die().click(function(){
 	
	$('.frombox .tab .li').removeClass("select");
	$(this).addClass("select");
 	$('.login_type').hide();
	data=$(this).attr('data');
	$('.'+data).show();
 
 });
 //手机动态码登录
  $("#J_dologin_mobile").die().click(function(){
			btn=$(this);
			btn.val('正在提交......').attr("disabled","disabled");
            m_mobile=$('input[name=m_mobile]').val();
			m_code=$('input[name=m_code]').val();
			m_auto=$('input[name=m_auto]').val();
			if (m_mobile==''){
				disapperTooltip("remind", "请填写手机号然后发送验证码");
				btn.val('登录').removeAttr("disabled");
				 return false;
			}
			if (m_mobile.length!=11){
				disapperTooltip("remind",'请填写正确的手机号');
				btn.val('登录').removeAttr("disabled");
				return false;
			}
			if (m_code==''){
				disapperTooltip("remind", "请填写验证码");
				btn.val('登录').removeAttr("disabled");
				return false;
			}
			 $.getJSON(ajaxURL,{ act:"ajax_mobile_login_code_verify",mobile:m_mobile,code:m_code,auto:m_auto}, function(json){
						if (json.status==0){
							btn.val('登录').removeAttr("disabled");
							disapperTooltip("remind",json.content);
						}else if (json.status==1){
							 // disapperTooltip("success",json.content);
													setTimeout(function () { 
														window.location.reload();
								}, 1800);
						}else{
							btn.val('登录').removeAttr("disabled");
							disapperTooltip("remind",json.content);
						}
					});
			 
			
        });
		
 //发送验证码
$("#J_send_code").click(function(){
					
					btn=$(this);
					if (btn.hasClass('btn_disabled')) return false;
					function settime(countdown) {
						if (countdown == 0) {
							$('#J_send_code').removeClass('btn_disabled');
							$('#J_send_code').text('获取验证码');
							countdown = 60;
							return;
						} else {
							$('#J_send_code').addClass('btn_disabled');
							$('#J_send_code').text('重新发送' + countdown + '秒');
							countdown--;
						}
						setTimeout(function() {
							settime(countdown)
						},1000)
					}
					var mobile=$('input[name=m_mobile]').val();
					if (mobile.length!=11){
						disapperTooltip("remind",'请填写正确的手机号');
						return false;
					}
					btn.addClass('btn_disabled').html('正在发送中.');
					$.getJSON(ajaxURL,{ act:"ajax_send_mobile_code",mobile:mobile}, function(json){
						if (json.status==0){
							btn.removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}else if (json.status==1){
							disapperTooltip("success",json.content);
							settime(60);
						}else{
							btn.removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}
					});
});
</script>